package A1_4_Shopsystem;

// 订单详情类
public class OrderDetail {
    private int quantity;
    private Product product; // 关联关系：一个订单详情对应一个商品
    private Order order;     // 组合关系：订单详情属于一个订单

    public OrderDetail(int quantity, Product product, Order order) {
        this.quantity = quantity;
        this.product = product;
        this.order = order;
    }

    // 计算小计金额
    public double calculateSubTotal() {
        return product.getPriceForQuantity(quantity);
    }

    // 计算总重量
    public double calculateWeight() {
        return product.getWeight() * quantity;
    }

    // Getter 方法
    public int getQuantity() {
        return quantity;
    }

    public Product getProduct() {
        return product;
    }

    public Order getOrder() {
        return order;
    }
}
